﻿Imports System.Data.OleDb
Imports System.Globalization
Imports System.Globalization.CultureInfo
Imports System.IO
Public Class browsem
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
    Protected Sub searchResults_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
        If searchResults.Items.Count < 1 Then
            If e.Item.ItemType = ListItemType.Footer Then
                Dim lblFooter As Label = CType(e.Item.FindControl("lblEmptyData"), Label)
                lblFooter.Visible = True
            End If
        End If
    End Sub

    Protected Sub submitadvancedsearch_Click(sender As Object, e As EventArgs) Handles submitadvancedsearch.Click
        Dim conn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BookMeetConnString").ConnectionString)
        conn.Open()
        Dim cmdsearch As New OleDbCommand("SELECT * FROM userprofiles WHERE (TravellerName LIKE '%' + ? + '%') ", conn)
        cmdsearch.Parameters.AddWithValue("@username", other.Text)
        searchResults.DataSource = cmdsearch.ExecuteReader()
        searchResults.DataBind()
        conn.Close()
    End Sub

    Protected Sub submitregionsearch_Click(sender As Object, e As EventArgs) Handles submitregionsearch.Click
        Dim conn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BookMeetConnString").ConnectionString)
        conn.Open()
        Dim cmdsearch As New OleDbCommand("SELECT * FROM userprofiles WHERE (Location = ?) ", conn)
        cmdsearch.Parameters.AddWithValue("@location", dd_userlocation.SelectedValue)
        searchResults.DataSource = cmdsearch.ExecuteReader()
        searchResults.DataBind()
        conn.Close()
    End Sub

    Protected Sub submitprofession_Click(sender As Object, e As EventArgs) Handles submitprofession.Click
        Dim conn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BookMeetConnString").ConnectionString)
        conn.Open()
        Dim cmdsearch As New OleDbCommand("SELECT * FROM userprofiles WHERE (Profession = ?) ", conn)
        cmdsearch.Parameters.AddWithValue("@profession", profession.SelectedValue)
        searchResults.DataSource = cmdsearch.ExecuteReader()
        searchResults.DataBind()
        conn.Close()
    End Sub

    Protected Sub submitbirthdatesearch_Click(sender As Object, e As EventArgs) Handles submitbirthdatesearch.Click
        Dim conn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BookMeetConnString").ConnectionString)
        conn.Open()
        Dim cmdsearch As New OleDbCommand("SELECT * FROM userprofiles WHERE (DOB = ?) ", conn)
        cmdsearch.Parameters.AddWithValue("@birthdate", DateTime.ParseExact(tb_age.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture))
        searchResults.DataSource = cmdsearch.ExecuteReader()
        searchResults.DataBind()
        conn.Close()
    End Sub
End Class